/*******************************************************************************
 * Copyright (c) 2006, 2020 Thales Global Services
 *   This program and the accompanying materials are made available under the
 *   terms of the Eclipse Public License 2.0 which is available at
 *   http://www.eclipse.org/legal/epl-2.0
 *   
 *   SPDX-License-Identifier: EPL-2.0
 * 
 *   Contributors:
 *      Thales - initial API and implementation
 ******************************************************************************/
package org.polarsys.capella.vp.price.price.impl;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

import org.polarsys.capella.common.lib.IdGenerator;

import org.polarsys.capella.vp.price.price.*;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class PriceFactoryImpl extends EFactoryImpl implements PriceFactory {
  /**
   * Creates the default factory implementation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public static PriceFactory init() {
    try {
      PriceFactory thePriceFactory = (PriceFactory) EPackage.Registry.INSTANCE.getEFactory(PricePackage.eNS_URI);
      if (thePriceFactory != null) {
        return thePriceFactory;
      }
    } catch (Exception exception) {
      EcorePlugin.INSTANCE.log(exception);
    }
    return new PriceFactoryImpl();
  }

  /**
   * Creates an instance of the factory.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PriceFactoryImpl() {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EObject create(EClass eClass) {
    switch (eClass.getClassifierID()) {
    case PricePackage.PRICE:
      return createPrice();
    case PricePackage.PART_PRICE:
      return createPartPrice();
    default:
      throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Price createPrice() {
    PriceImpl price = new PriceImpl();
    //begin-capella-code
    price.setId(IdGenerator.createId());
    //end-capella-code
    return price;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PartPrice createPartPrice() {
    PartPriceImpl partPrice = new PartPriceImpl();
    //begin-capella-code
    partPrice.setId(IdGenerator.createId());
    //end-capella-code
    return partPrice;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PricePackage getPricePackage() {
    return (PricePackage) getEPackage();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @deprecated
   * @generated
   */
  @Deprecated
  public static PricePackage getPackage() {
    return PricePackage.eINSTANCE;
  }

  //begin-capella-code

  /**
   * Creates class and sets its name
   * (This method comes from a customization of the standard EMF generator)
   *
   * @param name_p : default name of created element
   * @generated
   */
  public Price createPrice(String name_p) {
    Price price = createPrice();
    price.setName(name_p);
    return price;
  }

  /**
   * Creates class and sets its name
   * (This method comes from a customization of the standard EMF generator)
   *
   * @param name_p : default name of created element
   * @generated
   */
  public PartPrice createPartPrice(String name_p) {
    PartPrice partPrice = createPartPrice();
    partPrice.setName(name_p);
    return partPrice;
  }

  //end-capella-code
} //PriceFactoryImpl